package com.edu.exam.enums;

/**
 * 成绩导出权限状态枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum GradeExportPermissionStatus {
    /** 已申请 */
    REQUESTED("REQUESTED", "已申请"),
    /** 已批准 */
    APPROVED("APPROVED", "已批准"),
    /** 已拒绝 */
    REJECTED("REJECTED", "已拒绝"),
    /** 已激活 */
    ACTIVE("ACTIVE", "已激活"),
    /** 已暂停 */
    SUSPENDED("SUSPENDED", "已暂停"),
    /** 已过期 */
    EXPIRED("EXPIRED", "已过期"),
    /** 已撤销 */
    REVOKED("REVOKED", "已撤销"),
    /** 已取消 */
    CANCELLED("CANCELLED", "已取消");

    private final String code;
    private final String description;

    GradeExportPermissionStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static GradeExportPermissionStatus fromCode(String code) {
        if (code == null) {
            throw new IllegalArgumentException("Code cannot be null");
        }
        for (GradeExportPermissionStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }

    public static GradeExportPermissionStatus fromDescription(String description) {
        if (description == null) {
            throw new IllegalArgumentException("Description cannot be null");
        }
        for (GradeExportPermissionStatus status : values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}